<html xmlns="http://www.w3.org/1999/html">

<head>

    <style type="text/css">
        <!--
        body{background-color: #F1FCE0}

        #new_task_title{width:100%;height:50px;border:1px solid;padding:2px 6px;font-size:30px}
        #new_task_content{width:100%;height:80%;border:1px solid;padding:2px 6px}
        -->
    </style>
    <script type="text/javascript" src="util.js"></script>
    <script src="jquery.min.js"></script>
</head>

<body>

<div id="new_task_panel">

    <textarea id="new_task_title" placeholder="Title"></textarea>

    <p>
        <!--
        <label><input name="prority" type="radio" value="1"/>重要紧急</label>
        <label><input name="prority" type="radio" value="2"/>重要不紧急</label>
        <label><input name="prority" type="radio" value="3"/>紧急不重要</label>
        <label><input name="prority" type="radio" value="4"/>不紧急不重要</label>
        -->
        <input id="new_task_priority" type="text" value="0">
    </p>
    <textarea id="new_task_content" placeholder="Content"></textarea>
    <INPUT value="done" type="button" onClick="new_task_fn()">
</div>


<!-- JavaScript脚本，主要包括了按钮要执行的函数，显示对话框等 -->
<script type="text/javascript">

    function new_task_fn() {
         var title = document.getElementById("new_task_title");
         var content = document.getElementById("new_task_content");
         var priority = document.getElementById("new_task_priority");
         //alert("This is a alert sample from html"+title.value.length);
         if(title.value.length!=0)
            var id = getQueryString('id');
            if (id==null)
                Android.add_new_task(title.value,content.value,priority.value);
            else
                Android.update_task(id, title.value,content.value,priority.value);
         title.value="";
         content.value="";
         priority.value="";
         location.href="index.html";
     }

     function update_task()
     {
        var id = getQueryString('id');
        if (id==null)
            return;
        var title_node = document.getElementById("new_task_title");
        var content_node = document.getElementById("new_task_content");
        var priority_node = document.getElementById("new_task_priority");
        Android.get_task_by_id(id);
        var title=Android.get_title_by_id(id);
        var content=Android.get_content_by_id(id);
        var priority=Android.get_priority_by_id(id);

        $(title_node).val(title);
        $(content_node).val(content);
        $(priority_node).val(priority);
     }

     update_task();

</script>
</body>

</html>